#ifndef AUTOAIM_DETECTOR__DETECTOR_NODE_HPP_
#define AUTOAIM_DETECTOR__DETECTOR_NODE_HPP_

#include <vector>

#include <dynamic_reconfigure/server.h>
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <opencv2/opencv.hpp>

#include "configures/DetectorConfig.h"
#include "rm_interfaces/SetMode.h"

#include "detector/descriptor.hpp"
#include "detector/detector.hpp"

namespace detector {

class DetectorNode {
  using config_srv = dynamic_reconfigure::Server<detector::DetectorConfig>;

 public:
  DetectorNode();

 private:
  void image_cb(const sensor_msgs::ImageConstPtr &msg);

  cv::Mat drawResults(cv::Mat &src, const std::vector<Light> &lights,
                      const std::vector<Armor> &armors);

  void configure_cb(const detector::DetectorConfig &config, uint32_t level);

  bool set_mode_cb(rm_interfaces::SetMode::Request &request,
                   rm_interfaces::SetMode::Response &response);

 private:
  ros::NodeHandle nh_;
  ros::Subscriber img_sub_;
  ros::Publisher targets_pub_;
  ros::ServiceServer set_mode_server_;

  ros::Publisher binary_img_pub_;
  ros::Publisher number_img_pub_;
  ros::Publisher rgb_img_pub_;
  config_srv config_server_;
  config_srv::CallbackType f_;

  Detector::Ptr detector_;

  bool debug_;
  bool autoaim_start_;
  int enemy_color_;
  int lightness_thresh_;
  ros::Time last_time_;
};

}  // namespace detector
#endif  // AUTOAIM_DETECTOR__DETECTOR_NODE_HPP_